package com.acwing.partition19;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/1/26 17:05
 */
public class AC1843圆形牛棚_枚举 {

    private static final int N = 2010;
    private static int[] nums = new int[N];
    private static int n = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = Integer.parseInt(reader.readLine());
        for (int i = 0; i < n; i++) nums[i] = Integer.parseInt(reader.readLine());
        //4 7 8 6 4 | 4 7 8 6 4
        for (int i = n; i < 2 * n; i++) nums[i] = nums[i - n];
        int ans = 0x3f3f3f3f;
        //枚举每一个房间打开的情况
        for (int i = 0; i < n; i++) {
            int c = 0;
            for (int j = 1; j < n; j++) c += j * nums[i + j];
            ans = Math.min(ans, c);
        }
        writer.write(ans + "\n");
        writer.flush();
    }
}
